﻿using System;
using System.Collections.Generic;
using System.Text;
using Tauren.Business.DLL.Base;
using Tauren.Business.DLL.TableInfoDLL;
using Tauren.Business.DLL.Resouces;
using Tauren.Business.Entity.Config;
using Tauren.Business.Entity.Const;
using Tauren.Business.Entity.Enum;
using Tauren.Business.Entity.Global;
using Tauren.Business.Entity.Input;
using Tauren.Business.Entity.Model;
using Tauren.Business.Infrastructure.Globals;
using System.Linq;
using System.Transactions;
using Tauren.Business.Entity.Output;
using Tauren.Business.DLL.FieldsDLL;
using Tauren.Business.DLL.ParametersDLL;

namespace Tauren.Business.Service.FieldBLL
{
    /// <summary>
    /// 字典
    /// </summary>
    public class FieldService : Base.BaseService, IFieldService
    {
        private IFieldBusiness business;
        public ITableInfoBusiness tbbusiness { get; set; }
        public FieldService(IFieldBusiness _business, IConnectionBLLBase connectionBLL, IMenuResourcesBusiness resourcesBusiness) : base(_business, connectionBLL, resourcesBusiness)
        {
            this.business = _business;
            this.ResourcesInfo = this.GetResources(GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY);
            this.JudePrmission(GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower());
        }

        public IResponseMessage Add(Fields_InPut data)
        {
            if (!HavePermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            if (data is null) return GlobalErrorType.GLOBAL_NOT_FOUND_INPUT_DATA.Failure(this.CommonText(GlobalErrorType.GLOBAL_NOT_FOUND_INPUT_DATA));
            var codes = business.IsPermissionCodeRepeat(0, data.FieldCode,data.TableCode);
            if (codes) return GlobalErrorType.GLOBAL_REPEAT_CODE.Failure(this.CommonText(GlobalErrorType.GLOBAL_REPEAT_CODE));
            Fields fields;
            ToModel(data, out fields);
            fields.Enable = true;
            fields.HaveDelete = false;
            fields.Sequence = business.GetSeq();
            fields.Creator = this.Global.EmpId;
            fields.Modifier = this.Global.EmpId;
            fields.Creatdate = DateTime.Now;
            fields.Modifdate = DateTime.Now;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted }))
            {
                bool b = false;
                long id = business.Add(fields);
                if (id > 0)
                {
                    b = business.CreateField(fields);
                }
                TableInfo table = tbbusiness.Table(fields.TableCode);
                if (b && table.IsFlow.Value)
                {
                    fields.TableCode = table.FlowTableCode;
                    b = business.CreateField(fields);
                }
                if (b)
                {
                    ts.Complete();
                    return "".OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_SAVE_SUCCESSINFO.ToString()));
                }
                else return GlobalErrorType.GLOBAL_SAVE_FAILURE.OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_SAVE_FAILURE));
            }
        }

        public IResponseMessage Config(string PageType)
        {
            if (!HavePermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            List<OutPutConfig> Fields = new List<OutPutConfig>();

            OutPutConfig config = new OutPutConfig();
            config.Label = this.CommonText("fieldcode");
            config.FieldKey = "fieldCode";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.text;
            config.Show = true;
            config.Editor = PageType != "view" && PageType != "edit";
            config.Required = PageType != "view" && PageType != "edit";
            Dictionary<object, object> rule = new Dictionary<object, object>();
            if (PageType != "view" && PageType != "edit")
            {
                #region 添加验证规则

                rule.Add("required", true);
                rule.Add("message", this.Resources("fieldcoderequired"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
                ///长度
                rule = new Dictionary<object, object>();
                rule.Add("min", 1);
                rule.Add("max", 30);
                rule.Add("message", this.Resources("fieldcodemax"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
                ///正则
                rule = new Dictionary<object, object>();
                rule.Add("pattern", @"^[a-zA-Z]|([a-zA-Z]\w){1,30}$");
                rule.Add("message", this.Resources("fieldcoderegx"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            #endregion

            #region 中文名
            config = new OutPutConfig();
            config.Label = this.CommonText("thcnname");
            config.FieldKey = "fieldName";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.textarea;
            config.Show = true;
            config.Editor = PageType != "view";
            config.Required = PageType != "view";
            rule = new Dictionary<object, object>();
            if (PageType != "view")
            {
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
                ///长度
                rule = new Dictionary<object, object>();
                rule.Add("min", 1);
                rule.Add("max", 100);
                rule.Add("message", this.Resources("fieldnamemax"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            #endregion
            #region 英文名
            config = new OutPutConfig();
            config.Label = this.CommonText("thenname");
            config.FieldKey = "fieldENName";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.textarea;
            config.Show = true;
            config.Editor = PageType != "view";
            config.Required = PageType != "view";
            rule = new Dictionary<object, object>();
            if (PageType != "view")
            {
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
                ///长度
                rule = new Dictionary<object, object>();
                rule.Add("min", 1);
                rule.Add("max", 200);
                rule.Add("message", this.Resources("fieldennamemax"));
                rule.Add("trigger", "blur");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            #endregion     

            config = new OutPutConfig();
            config.Label = this.Resources("thcontrolstype");
            config.FieldKey = "controlStype";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.parameter;
            config.Show = true;
            config.Editor = PageType != "view" && PageType != "edit";
            config.Required = PageType != "view" && PageType != "edit";
            config.Options = EnumComm.EnumControlType();
            config.Options.ForEach(o => o.Label = CommonText($"field{o.Label}"));
            config.ValueField = "fieldType";
            if (PageType != "view" && PageType != "edit")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);

            config = new OutPutConfig();
            config.Label = this.Resources("thcontrolsouces");
            config.FieldKey = "controlSouces";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.parameter;
            config.Show = true;
            config.Editor = PageType != "view" && PageType != "edit";
            config.Required = PageType != "view" && PageType != "edit";
            business.All<Parameters>().Where(o => !o.HaveDelete.Value && o.Enable.Value).ToList().ForEach(o =>
                {
                    config.Options.Add(new Entity.Output.Options() { Label = Global.IsChinese ? o.CNName : o.ENName, Value = o.Code });
                });
            config.Conditions.Add(new Entity.Output.Options() { Label = "controlStype", Value = ControlType.parameter.ToString() });

            if (PageType != "view" && PageType != "edit")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            config = new OutPutConfig();
            config.Label = this.Resources("thselectType");
            config.FieldKey = "selectType";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.parameter;
            config.Show = true;
            config.Editor = PageType != "view" && PageType != "edit";
            config.Required = PageType != "view" && PageType != "edit";
            config.Options = EnumComm.EnumSelectType();
            config.Options.ForEach(o => { o.Label = CommonText($"field{o.Label}"); });
            config.Conditions.Add(new Entity.Output.Options() { Label = "controlStype", Value = ControlType.parameter.ToString() });
            config.Conditions.Add(new Entity.Output.Options() { Label = "controlStype", Value = ControlType.employee.ToString() });
            config.Conditions.Add(new Entity.Output.Options() { Label = "controlStype", Value = ControlType.organizational.ToString() });
            config.Conditions.Add(new Entity.Output.Options() { Label = "controlStype", Value = ControlType.position.ToString() });

            if (PageType != "view" && PageType != "edit")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);

            config = new OutPutConfig();
            config.Label = this.Resources("thfieldtype");
            config.FieldKey = "fieldType";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.parameter;
            config.Show = true;
            config.Editor = PageType != "view" && PageType != "edit";
            config.Required = PageType != "view" && PageType != "edit";
            config.Options = EnumComm.EnumFieldType("controlStype");
            config.Options.ForEach(o => { o.Label = CommonText($"field{o.Label}"); });
            if (PageType != "view" && PageType != "edit")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            config = new OutPutConfig();
            config.Label = this.Resources("thfieldlength");
            config.FieldKey = "fieldLength";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.number;
            config.Show = true;
            config.Editor = PageType != "view";
            config.Required = PageType != "view";
            config.Conditions.Add(new Entity.Output.Options() { Label = "fieldType", Value = FieldType.varchar });
            if (PageType != "view")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);

            config = new OutPutConfig();
            config.Label = this.Resources("thisrequired");
            config.FieldKey = "isRequired";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.radio;
            config.Show = true;
            config.Editor = PageType != "view";
            config.Required = PageType != "view";
            config.Options = new List<Options>() {
                new Options { Label=CommonText("globalyes") ,Value= true },
                new Options { Label=CommonText("globalno") ,Value=false },
            };
            if (PageType != "view")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);

            config = new OutPutConfig();
            config.Label = this.Resources("thisinlay");
            config.FieldKey = "isInlay";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.radio;
            config.Show = true;
            config.Editor = PageType != "view";
            config.Required = PageType != "view";
            config.Options = new List<Options>() {
               new Options { Label=CommonText("globalyes") ,Value= true },
                new Options { Label=CommonText("globalno") ,Value= false },
            };
            if (PageType != "view")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            config = new OutPutConfig();
            config.Label = this.Resources("thprecisions");
            config.FieldKey = "precisions";
            config.MenuCode = GlobalConst.RESOURCES_FLAG_MODULE_TABLEINFO_KEY.ToLower();
            config.ControlType = ControlType.number;
            config.Show = true;
            config.Editor = PageType != "view";
            config.Required = PageType != "view";
            config.Conditions.Add(new Entity.Output.Options() { Label = "fieldType", Value = FieldType.doubled });
            if (PageType != "view")
            {
                rule = new Dictionary<object, object>();
                rule.Add("required", true);
                rule.Add("message", this.CommonText("fieldsrequired"));
                rule.Add("trigger", "change");
                config.Rules.Add(rule);
            }
            Fields.Add(config);
            return Fields.Succeed();
        }

        public IResponseMessage Delete(long AutoID)
        {
            if (!HavePermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            var data = business.Get<Fields>(AutoID);
            if (data is null) return GlobalErrorType.GLOBAL_NOT_FOUND_DB_DATA.Failure(this.CommonText(GlobalErrorType.GLOBAL_NOT_FOUND_DB_DATA));
            data.Enable = false;
            data.HaveDelete = true;
            data.Modifier = Global.EmpId;
            data.Modifdate = DateTime.Now;
            bool b = business.Update<Fields>(data);
            if (b)
            {
                return "".OnSucceed(this.Resources(GlobalErrorType.GLOBAL_DELETE_SUCCESSINFO));
            }
            else return GlobalErrorType.GLOBAL_DELETE_FAILURE.OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_DELETE_FAILURE));
        }

        public IResponseMessage Edit(Fields_InPut data)
        {
            if (!HavePermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            if (data is null) return GlobalErrorType.GLOBAL_NOT_FOUND_INPUT_DATA.Failure(this.CommonText(GlobalErrorType.GLOBAL_NOT_FOUND_INPUT_DATA));
            var singe = business.Get<Fields>(data.AutoId);
            if (singe is null) return GlobalErrorType.GLOBAL_NOT_FOUND_DB_DATA.Failure(this.CommonText(GlobalErrorType.GLOBAL_NOT_FOUND_DB_DATA));
            var codes = business.IsPermissionCodeRepeat(data.AutoId, data.FieldCode, data.TableCode);
            if (codes) return GlobalErrorType.GLOBAL_REPEAT_CODE.Failure(this.CommonText(GlobalErrorType.GLOBAL_REPEAT_CODE));
            Fields fields;
            ToModel(data, out fields);
            fields.Sequence = singe.Sequence;
            fields.Enable = singe.Enable;
            fields.HaveDelete = singe.HaveDelete;
            fields.Creatdate = singe.Creatdate;
            fields.Creator = singe.Creator;
            fields.Modifier = this.Global.EmpId;
            fields.Modifdate = DateTime.Now;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted }))
            {
                bool b = business.Update(fields);
                if (b)
                {
                    b = business.EditField(fields);
                    TableInfo table = tbbusiness.Table(fields.TableCode);
                    if (b && table.IsFlow.Value)
                    {
                        b = business.EditField(fields);
                    }
                }
                if (b)
                {
                    ts.Complete();
                    return "".OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_SAVE_SUCCESSINFO.ToString()));
                }
                else return GlobalErrorType.GLOBAL_SAVE_FAILURE.OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_SAVE_FAILURE));
            }
        }

        public IResponseMessage Enable(long AutoID)
        {
            if (!HavePermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            var data = business.Get<Fields>(AutoID);
            if (data is null) return GlobalErrorType.GLOBAL_NOT_FOUND_DB_DATA.Failure(this.CommonText(GlobalErrorType.GLOBAL_NOT_FOUND_DB_DATA));
            data.Enable = !data.Enable;
            data.Modifier = Global.EmpId;
            data.Modifdate = DateTime.Now;
            bool b = business.Update<Fields>(data);
            if (b)
            {
                return "".OnSucceed(this.CommonText(data.Enable ? GlobalErrorType.GLOBAL_ENABLE_SUCCESSINFO : GlobalErrorType.GLOBAL_DISABLE_SUCCESSINFO));
            }
            else return data.Enable ? GlobalErrorType.GLOBAL_ENABLE_FAILURE.OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_ENABLE_FAILURE)) : GlobalErrorType.GLOBAL_DISABLE_FAILURE.OnSucceed(this.CommonText(GlobalErrorType.GLOBAL_DISABLE_FAILURE));
        }

        public IResponseMessage Get(long AutoID)
        {
            if (!HavePermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            Fields fields = business.Get<Fields>(AutoID);
            Fields_OutPut _OutPut = new Fields_OutPut();
            if (fields != null)
            {
                ToViewModel(fields, out _OutPut);
            }
            return _OutPut.Succeed();
        }

        public IResponseMessage Pages(QueryModel queryModel)
        {
            if (!HavePermission && queryModel.CheckPermission) return ErrorType.BUSINESS_WITHOUT_PERMISSION.Failure(this.CommonText(ErrorType.BUSINESS_WITHOUT_PERMISSION));
            TableListModel<PageFieldsTable> tableListModel = new TableListModel<PageFieldsTable>();
            List<TableListHeaderModele> Headers = new List<TableListHeaderModele>();
            Headers.Add(new TableListHeaderModele() { Key = "rowNo", Name = CommonText("rowNo"), Width = 50, Align = "center", Fixed = true });
            Headers.Add(new TableListHeaderModele() { Key = "autoId", Name = CommonText("autoid"), Width = 70, Hide = true, Type = "primary_key", Align = "center", SorTable = SortType.custom.ToString(), Fixed = true });
            Headers.Add(new TableListHeaderModele() { Key = "tableName", Name = CommonText("thtablename"), Width = 160, Align = "left", SorTable = SortType.custom.ToString(), Fixed = true });
            Headers.Add(new TableListHeaderModele() { Key = "fieldCode", Name = CommonText("fieldcode"), Width = 160, Align = "left", SorTable = SortType.custom.ToString(), Fixed = true });
            Headers.Add(new TableListHeaderModele() { Key = "fieldName", Name = CommonText("thcnname"), Align = "left", IsOperation = true, SorTable = SortType.custom.ToString(), Fixed = true });
            Headers.Add(new TableListHeaderModele() { Key = "fieldENName", Name = CommonText("thenname"), Width = 220, Align = "left", SorTable = SortType.custom.ToString() });
            Headers.Add(new TableListHeaderModele() { Key = "dic_ControlStype", Name = Resources("thcontrolstype"), Width = 120, Align = "center", IsTag = true, SorTable = SortType.custom.ToString() });
            Headers.Add(new TableListHeaderModele() { Key = "dic_FieldType", Name = Resources("thfieldtype"), Width = 120, Align = "center", IsTag = true, SorTable = SortType.custom.ToString() });
            Headers.Add(new TableListHeaderModele() { Key = "dic_Enable", Name = CommonText("thstate"), IsTag = true, Width = 100, Align = "center", SorTable = SortType.custom.ToString() });
            Headers.Add(new TableListHeaderModele() { Key = "dic_Creator", Name = CommonText("diccreator"), Width = 120, Align = "center" });
            Headers.Add(new TableListHeaderModele() { Key = "dic_Creatdate", Name = CommonText("diccreatdate"), Width = 160, Align = "center" });
            Headers.Add(new TableListHeaderModele() { Key = "action", Name = "操作", Width = 160, Align = "center" });
            long Total = 0;
            List<PageFieldsTable> Data = business.Pages(queryModel, out Total);
            if (Data.Any())
            {
                Data.ForEach(o =>
                {
                    o.Dic_ControlStype = CommonText($"field{o.ControlStype}");
                    o.Dic_FieldType = CommonText($"field{((FieldType)o.FieldType).ToString()}");
                    o.Dic_Enable = CommonText(o.Enable ? GlobalConst.RESOURCES_CONTENT_ENABLE_KEY : GlobalConst.RESOURCES_CONTENT_DISABLE_KEY);
                    o.Dic_Creator = EmpDictionary.ContainsKey(o.Creator) ? EmpDictionary[o.Creator] : "";
                    o.Dic_Creatdate = o.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                    o.Row_Style = o.Enable ? "" : "danger";
                    o.Operations = new List<SystemButton>();
                    if (Global.IsAdmin && (Buttons is null || !Buttons.Any()))
                    {
                        BuliderButtons(o.Operations, o.TableCode, o.AutoId, ButtomType.edit);
                        BuliderButtons(o.Operations, o.TableCode, o.AutoId, ButtomType.detaile);
                        BuliderButtons(o.Operations, o.TableCode, o.AutoId, !o.Enable ? ButtomType.enable : ButtomType.disable);
                        BuliderButtons(o.Operations, o.TableCode, o.AutoId, ButtomType.delete);
                    }
                    else
                    {
                        if (Buttons.Any(o => o.Location == ButtomLocation.center.ToString() && o.Value == ButtomType.edit.ToString()))
                            BuliderButtons(o.Operations, o.TableCode, o.AutoId, ButtomType.edit);
                        if (Buttons.Any(o => o.Location == ButtomLocation.center.ToString() && o.Value == ButtomType.detaile.ToString()))
                            BuliderButtons(o.Operations, o.TableCode, o.AutoId, ButtomType.detaile);
                        if (Buttons.Any(o => o.Location == ButtomLocation.center.ToString() && (o.Value == ButtomType.enable.ToString() || o.Value == ButtomType.disable.ToString())))
                            BuliderButtons(o.Operations, o.TableCode, o.AutoId, !o.Enable ? ButtomType.enable : ButtomType.disable);
                        if (Buttons.Any(o => o.Location == ButtomLocation.center.ToString() && o.Value == ButtomType.delete.ToString()))
                            BuliderButtons(o.Operations, o.TableCode, o.AutoId, ButtomType.delete);
                    }
                });
            }
            tableListModel.Body = Data;
            tableListModel.Total = Total;
            tableListModel.Header = Headers;
            if (Global.IsAdmin && (Buttons is null || !Buttons.Any()))
            {
                BuliderButtons(tableListModel.Operations, "", 0, ButtomType.add);
            }
            else
            {
                if (Buttons.Any(o => o.Value == ButtomType.add.ToString()))
                    BuliderButtons(tableListModel.Operations, "", 0, ButtomType.add);
            }
            return tableListModel.Succeed();
        }
    }
}
